const express = require('express');
var server = express();
//cookie
const cookieparser = require('cookie-parser');
const cookiesession = require('cookie-session');
//                       签名和sercet要一致
server.use(cookieparser('yuonly123123123'));
server.use(cookiesession({
    //session要有效，必须设置keys。
    keys:['111','2222','3333','4444','555'],
    name:'sess',//修改cookie中 session的名字
    maxAge:30*3600*1000 //过期时间
}));
server.use('/',function(req,res){
    if(req.session['count']==null){
        req.session['count'] = 1;
    }else{
        req.session['count']++;
    }
    console.log(req.session['count']);
    res.send('ok');
    res.end();
});
server.listen(8080);
